﻿// JScript 文件
function WinOpen(pageUrl,target,WinWidth,WinHeight) 
{ 
	var popwin=window.open(pageUrl,target,"scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width="+WinWidth+",height="+WinHeight + ",left=" + (screen.width-WinWidth)/2 + ",top=" + (screen.height-WinHeight-100)/2); 
	popwin.focus();
	return false; 
}
function WinOpen(pageUrl,target,WinWidth,WinHeight,scrollbars) 
{ 
	var popwin=window.open(pageUrl,target,"scrollbars="+scrollbars+",toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width="+WinWidth+",height="+WinHeight + ",left=" + (screen.width-WinWidth)/2 + ",top=" + (screen.height-WinHeight-100)/2); 
	popwin.focus();
	return false; 
}
function WinOpenImage(pageUrl,target,WinWidth,WinHeight) 
{ 
	var popwin=window.open(pageUrl,target,"scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,width="+WinWidth+",height="+WinHeight + ",left=" + (screen.width-WinWidth)/2 + ",top=0"); 
	popwin.focus();
	return false;
}

function GetRootPath() {
    var rootPath = "";
    var list = document.location.pathname.split('/');
    if (list.length > 1 && list[1] != "") {
        rootPath = list[1];
    }
    rootPath = "/" + rootPath;
    return rootPath;
}
function openPopWin(url, width, height, callback, title) {
  if (url.indexOf("http://") == -1) {
        url = GetRootPath() + url
    }
    top.openPopWindow(window, title, url, callback, true, width, height);
}

function closePopWin() {
    while (parent != undefined) {
        if (parent.closedlg != undefined) {
            parent.closedlg();
            break;
        }
    }
}
function turnit(obj)
{
	var submenu = document.getElementById(obj);
	if(submenu.style.display == "none")
	{
		submenu.style.display = "";
	}
	else
	{
		submenu.style.display = "none";
	}
	
}

function quit()
{
	if(window.confirm("确定要退出系统！"))
	{
		var btn = top.midFrame.document.getElementById("btnClose");
		btn.click();
		top.location.href="quit.aspx";
	}
}
			
function openWin(url,w,h)
{
	var t= 80;
	var l = window.screen.availWidth - 800;
	var hh =window.open(url,"aa","height=" + h + ", width=" + w + ", top=" + t + ", left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no");
	hh.focus();
}
			
function openWinA(url)
{
	var h,w,t,l;
	h = window.screen.availHeight-350;
	w = 820;
	l = window.screen.availWidth - 1000;
	var hhA = window.open(url,"A","height=" + h + ", width=" + w + ", top=100, left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no");
	hhA.focus();
}
			
function openWinAA(url)
{
	var h,w,t,l;
	h = window.screen.availHeight-250;
	w = 825;
	l = window.screen.availWidth - 1000;
	var hhAA = window.open(url,"AA","height=" + h + ", width=" + w + ", top=50, left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no");
    hhAA.focus();
   
}

function openWinAANew(url)
{

	var h,w,t,l;
	h = 300;
	w = 825;
	l = window.screen.availWidth - 1000;
	var hhAA = window.open(url,"AA","height=" + h + ", width=" + w + ", top=200, left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no");
    hhAA.focus();
   
}
function openWinAANew1(url,h,w,t)
{

	var h,w,t,l;
//	h = 300;
//	w = 825;
	l = 150;
	var hhAA = window.open(url,"AA","height=" + h + ", width=" + w + ", top="+t+", left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no");
    hhAA.focus();
   
}
// 针对有选择框的弹出框
function openWinAANew2(url,w,h,t,l,windowName) {
    if (windowName) windowName = "AA";
    //var h, w, t, l;
    if (!Boolean(Number(w))) w = window.screen.width * 0.7;
    if (!Boolean(Number(h))) h = 430;
    if (!Boolean(Number(t))) t = window.screen.width * 0.15;
    if (!Boolean(Number(l))) l = window.screen.height * 0.2;
    var hhAA = window.open(url, windowName, "height=" + h + ", width=" + w + ", top=" + t + ", left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no");
    hhAA.focus();
   
}

function openWin(url, w, h, t, l) {
    var hhAA = window.open(url, "AA", "height=" + h + ", width=" + w + ", top=" + t +", left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no");
    hhAA.focus();
}

function openWinMax(url)
{
    windowprops = "top=0,left=0,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes" + ",width=" + (screen.availWidth - 10) + ",height=" + (screen.availHeight - 50);
    //'toolbar=no,location=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=996,height=700,top=0,left=10'
    window.open(url, 'MgrDetail', windowprops, true);
}



   

function openCustom(url, name, h, w, scroll)
{
    if (h == null)
    {
        h = window.screen.availHeight - 350;
    }
    if (w == null)
    {
        w = 630;
    }
    var t = window.screen.availHeight / 2 - h / 2;
    var l = window.screen.availWidth / 2 - w / 2;
    var hh = window.open(url, name, "height=" + h + ", width=" + w + ", top=" + t + ", left=" + l + ", toolbar=no, menubar=no, scrollbars=" + scroll + ", resizable=no,location=no, status=no");
    hh.focus();
}

function openWinBy(url,w,h,t) {
    var l;
    l = window.screen.availWidth - 1000;
    var hhAA = window.open(url, "AA", "height=" + h + ", width=" + w + ", , left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no");
    hhAA.focus();
}

function openWinB(url)
{
	var h,w,t,l;
	h = window.screen.availHeight-200;
	w = 760;
	l = window.screen.availWidth - 800;
	var hhB = window.open(url,"cc","height=" + h + ", width=" + w + ", top=0, left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no");
	hhB.focus();
}
function openPrintWin(url)
{
	var h,w,t,l;
	h = 600;
	w = 800;
	l = window.screen.availWidth - 1000;
	var hhB = window.open(url,"cc","height=" + h + ", width=" + w + ", top=100, left=" + l + ", toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no");
	hhB.focus();
}
			
function init() 
{ 
	document.onkeydown=keyDown;
	document.Form1.txtCustName.focus();
	
} 

function keyDown(e) 
{  
	if(event.keyCode==13) 
	{ 
		if(!(event.srcElement.name=="btnSave"||event.srcElement.name=="btnMatch"||event.srcElement.name=="btnShop"))
		event.keyCode=9 
	} 
}

function DoCal(elTarget) 
{
	if (showModalDialog) 
	{
		var sRtn;
		var h,w;
		var w = event.clientX + document.body.scrollLeft + 50;
		var h = event.clientY + document.body.scrollTop + 50;
		//h=document.forms[0].sel.clientTop+document.forms[0].sel.offsetTop+140;
		//w=document.forms[0].sel.clientLeft+document.forms[0].sel.offsetLeft+280;
		//sRtn = showModalDialog("include/Calendar.htm","","center=yes;dialogWidth=121pt;dialogHeight=155pt;dialogTop="+h+"pt;dialogLeft="+w+"pt;status=no");
		
		sRtn = showModalDialog("../include/Calendar.htm","","center=yes;dialogWidth=121pt;dialogHeight=155pt;dialogTop="+h+"pt;dialogLeft="+w+"pt;status=no;scrollbars=no");
		if (sRtn!="")
		elTarget.value = sRtn;
	} 
	else
		alert("请安装最新版本的浏览器！")
}

function SelectAll()
{
	var theForm, intCount;

	theForm = document.forms[0];

	for (intCount=0;intCount<theForm.elements.length;intCount++) {
		if ((theForm.elements[intCount].name != "chkSelectAll") && (theForm.elements[intCount].name.substring(0,9) == "chkSelect"))
			theForm.elements[intCount].checked = theForm.chkSelectAll.checked;
	}
//	return true;
}
